package org.client.otdr;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;

public class BrowserLauncherButton extends Button {

	public BrowserLauncherButton() {
		this.setText("Browser");
		this.setOnAction(new EventHandler<ActionEvent>() {

			@Override
			public void handle(ActionEvent arg0) {
				launchBrowser();
			}
			
		});
	}

	protected void launchBrowser() {
		try {            
			Desktop desktop = Desktop.getDesktop();            
			desktop.browse(new URI("http://localhost:8080/JsUi.html"));   
		//	desktop.browse(new URI("http://"+InetAddress.getLocalHost().getHostAddress()+":8080/JsUi.html"));            
		} 
		catch (URISyntaxException ex) {            
			ex.printStackTrace();        
		} 
		catch (IOException ex) {            
			ex.printStackTrace();        
		}
	}
}
